package com.doublefish.doublefishrobot.ui.home.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.doublefish.doublefishrobot.R;
import com.doublefish.doublefishrobot.ui.home.bean.DeviceBean;
import com.doublefish.doublefishrobot.utils.ble.bean.ModeConstant;

import java.util.List;

/**
 * 作者:dugaofeng on 2024/10/18 10:14
 */
public class BindDeviceListAdapter extends BaseQuickAdapter<DeviceBean,BindDeviceListAdapter.BindDeviceHolder> {

    private Context mContext;

    public BindDeviceListAdapter(Context context, List<DeviceBean> data) {

        super(R.layout.item_bind_device, data);
        mContext = context;
    }

    @Override
    protected void convert(BindDeviceListAdapter.BindDeviceHolder helper, DeviceBean item) {
        helper.nameTv.setText(item.getAlias());
        helper.typeTv.setText(item.getDeviceTypeName());

        int resId = R.mipmap.icon_default;
        if (item.getDeviceType() == ModeConstant.DeviceTypeS8) {
            resId = R.mipmap.super8_2;
        } else if (item.getDeviceType() == ModeConstant.DeviceTypeS6) {
            resId = R.mipmap.super6_2;
        } else if (item.getDeviceType() == ModeConstant.DeviceTypeS5) {
            resId = R.mipmap.super_5;
        } else if (item.getDeviceType() == ModeConstant.DeviceTypeS3) {
            resId = R.mipmap.super_3;
        }
        helper.iconImageView.setImageResource(resId);
    }


    class BindDeviceHolder extends BaseViewHolder {
        TextView nameTv;
        TextView typeTv;
        ImageView iconImageView;

        public BindDeviceHolder(View view) {
            super(view);

            iconImageView = view.findViewById(R.id.iv_icon);
            nameTv = view.findViewById(R.id.tv_name);
            typeTv = view.findViewById(R.id.tv_device_type);
        }
    }
}

